import datetime
import os
import random
import string
import time


def get_time_string():
    """
    :return: 20220525140635467912
    :PS ：并发较高时尾部随机数增加
    """
    time_string = str(datetime.datetime.fromtimestamp(time.time())).replace("-", "").replace(" ", "").replace(":","").replace(".", "") + str(random.randint(100, 999))
    return time_string


def split_file_type(file):
    """
    对文件名切割，获取名字和类型
    """
    file_li = os.path.splitext(file)
    return file_li[0], file_li[1]


def selected_chrs(length):
    """
    返回length个随机字符串
    :param length:
    :return:
    """
    # 候选字符集,大小写字母
    chrs = string.ascii_letters
    result = ''.join(random.choice(chrs) for _ in range(length))
    return result


if __name__ == '__main__':
    print(selected_chrs(6))

